package flc.ast.adapter;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.CenterBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class DrawCenterAdapter extends StkProviderMultiAdapter<CenterBean> {

    public DrawCenterAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(150));
        addItemProvider(new DrawCenterProvider());
    }


    private class DrawCenterProvider extends BaseItemProvider<CenterBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_draw_center;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, CenterBean bean) {
            if (bean.isAvatar()){
                baseViewHolder.getView(R.id.ivDrawCenterItemImg).setVisibility(View.GONE);
                baseViewHolder.getView(R.id.ivDrawCenterItemAvatar).setVisibility(View.VISIBLE);
                Glide.with(getContext()).load(bean.getImg())
                        .into((ImageView) baseViewHolder.getView(R.id.ivDrawCenterItemAvatar));
            }else {
                baseViewHolder.getView(R.id.ivDrawCenterItemImg).setVisibility(View.VISIBLE);
                baseViewHolder.getView(R.id.ivDrawCenterItemAvatar).setVisibility(View.GONE);
                Glide.with(getContext()).load(bean.getImg())
                        .into((ImageView) baseViewHolder.getView(R.id.ivDrawCenterItemImg));
            }
        }
    }
}
